package com.xbongbong.paas.enums.bi;

import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 连接方式枚举
 * @author zcp
 * @since v1.0
 * @version v1.0
 */
@Getter
public enum DataSetJoinEnum {
    /**
     * 左连接
     */
    LEFT(1, "left", "left join"),
    /**
     * 右连接
     */
    RIGHT(2, "right", "right join"),
    /**
     * 内连接
     */
    INNER(3, "inner", "inner join"),
    ;
    private int code;
    private String alias;
    private String join;

    DataSetJoinEnum(int code, String alias, String join) {
        this.code = code;
        this.alias = alias;
        this.join = join;
    }

    /**
     * 根据alias获取枚举
     * @param alias
     * @return
     */
    public static DataSetJoinEnum getByAlias(String alias){
        return Arrays.stream(values()).filter(cache -> Objects.equals(cache.getAlias(), alias)).findAny().orElse(null);
    }
}
